// 主模块，初始化和协调
(function() {
  // 初始化时触发的逻辑
  console.log("仪表盘初始化完成");
  document.addEventListener("DOMContentLoaded", function() {
    // 添加地区选择事件监听
    window.EventBus.on("districtSelected", function(district) {
      console.log("选中香港区域:", district.name, "人口密度:", district.value);
      updateChartsForDistrict(district);
    });
    function updateChartsForDistrict(district) {
      window.EventBus.emit("updateBarChart", district);
      window.EventBus.emit("updateBarChart1", district);
    }
  });
  // 添加页面级别的事件监听
  $(".panel").click(function() {
    const panelName = $(this).attr("class").split(" ")[0];
    console.log("点击了面板:", panelName);

    // 广播面板点击事件
    EventBus.emit("panelClicked", panelName);
  });
  // 添加定时器，每隔一段时间切换年份
  setInterval(function() {
    const currentYear = Config.getCurrentYear();
    const newYear = currentYear === "2019" ? "2020" : "2019";
    Config.setCurrentYear(newYear);
  }, 10000); // 每10秒切换一次
})();
